package website.seamonster.ethegg.dataobject;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * Created by 罗海量
 * 2018-08-22 10:44
 */
@Entity
@Table(name = "eth_debug_buy")
@Slf4j
@Data
@DynamicInsert
@DynamicUpdate
public class DebugBuy {

    private long id;
    private long blockNum;
    private String txHash;
    private String fromAddress;
    private String toAddress;
    private BigDecimal amt;
    private long eggId;
    private Integer eggStatus;
    private long chickenId;

    @Id
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Basic
    @Column(name = "BLOCK_NUM")
    public long getBlockNum() {
        return blockNum;
    }

    public void setBlockNum(long blockNum) {
        this.blockNum = blockNum;
    }

    @Basic
    @Column(name = "TX_HASH")
    public String getTxHash() {
        return txHash;
    }

    public void setTxHash(String txHash) {
        this.txHash = txHash;
    }

    @Basic
    @Column(name = "FROM_ADDRESS")
    public String getFromAddress() {
        return fromAddress;
    }

    public void setFromAddress(String fromAddress) {
        this.fromAddress = fromAddress;
    }

    @Basic
    @Column(name = "TO_ADDRESS")
    public String getToAddress() {
        return toAddress;
    }

    public void setToAddress(String toAddress) {
        this.toAddress = toAddress;
    }

    @Basic
    @Column(name = "AMT")
    public BigDecimal getAmt() {
        return amt;
    }

    public void setAmt(BigDecimal amt) {
        this.amt = amt;
    }

    @Basic
    @Column(name = "EGG_ID")
    public long getEggId() {
        return eggId;
    }

    public void setEggId(long eggId) {
        this.eggId = eggId;
    }

    @Basic
    @Column(name = "EGG_STATUS")
    public Integer getEggStatus() {
        return eggStatus;
    }

    public void setEggStatus(Integer eggStatus) {
        this.eggStatus = eggStatus;
    }

    @Basic
    @Column(name = "CHICKEN_ID")
    public long getChickenId() {
        return chickenId;
    }

    public void setChickenId(long chickenId) {
        this.chickenId = chickenId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        DebugBuy debugBuy = (DebugBuy) o;

        if (id != debugBuy.id) return false;
        if (blockNum != debugBuy.blockNum) return false;
        if (eggId != debugBuy.eggId) return false;
        if (chickenId != debugBuy.chickenId) return false;
        if (txHash != null ? !txHash.equals(debugBuy.txHash) : debugBuy.txHash != null) return false;
        if (fromAddress != null ? !fromAddress.equals(debugBuy.fromAddress) : debugBuy.fromAddress != null)
            return false;
        if (toAddress != null ? !toAddress.equals(debugBuy.toAddress) : debugBuy.toAddress != null) return false;
        if (amt != null ? !amt.equals(debugBuy.amt) : debugBuy.amt != null) return false;
        if (eggStatus != null ? !eggStatus.equals(debugBuy.eggStatus) : debugBuy.eggStatus != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (int) (blockNum ^ (blockNum >>> 32));
        result = 31 * result + (txHash != null ? txHash.hashCode() : 0);
        result = 31 * result + (fromAddress != null ? fromAddress.hashCode() : 0);
        result = 31 * result + (toAddress != null ? toAddress.hashCode() : 0);
        result = 31 * result + (amt != null ? amt.hashCode() : 0);
        result = 31 * result + (int) (eggId ^ (eggId >>> 32));
        result = 31 * result + (eggStatus != null ? eggStatus.hashCode() : 0);
        result = 31 * result + (int) (chickenId ^ (chickenId >>> 32));
        return result;
    }
}
